#!/bin/bash

set -e

if [[ "${is_minimal}" = "true" ]]; then
    return 0
elif [[ "${is_ghost}" = "true" ]]; then
    return 0
fi

sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list

### TODO v10pro only
DISTRIB_RELEASE=$(grep -r PRETTY_NAME= /etc/os-release)
DISTRIB_RELEASE=${DISTRIB_RELEASE#*=}

case ${DISTRIB_RELEASE} in
    '"Kylin V10 SP1"')
        echo "
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.1 main restricted universe multiverse
deb http://archive.kylinos.cn/kylin/partner 10.1 main" >/etc/apt/sources.list
        ;;
    '"Kylin V10"')
        echo "
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.0 main restricted universe multiverse
" >/etc/apt/sources.list
        ;;
    *)
	rm -f /etc/apt/sources.list.d/kylin.list ||true
        echo "
deb http://archive.build.openkylin.top/openkylin/ yangtze main cross pty
deb http://archive.build.openkylin.top/openkylin/ yangtze-security main cross pty
deb http://archive.build.openkylin.top/openkylin/ yangtze-updates main cross pty
" >/etc/apt/sources.list
        ;;
esac
